home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0"?>
- <overlay id="repagination"
- xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:html="http://www.w3.org/1999/xhtml"
- >
-
- <script type="application/x-javascript" src="chrome://repagination/content/javascript.js"/>
-
- <script type="application/x-javascript">
- <![CDATA[
-
- /* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Paste and Go.
- *
- * The Initial Developer of the Original Code is Jens Bannmann.
- * Portions created by the Initial Developer are Copyright (C) 2003
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s) (alphabetical order):
- * Jens Bannmann <jens.b@web.de>
- * Oliver Aeberhard <aeberhard@gmx.ch>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-
- repagination =
- {
- regxNumber : /[0-9]+/,
- regx2Numbers : /[0-9]+[^0-9][0-9]+/,
- getContents : function(aURL)
- {
- var ioService=Components.classes["@mozilla.org/network/io-service;1"]
- .getService(Components.interfaces.nsIIOService);
- var scriptableStream=Components
- .classes["@mozilla.org/scriptableinputstream;1"]
- .getService(Components.interfaces.nsIScriptableInputStream);
- var channel=ioService.newChannel(aURL,null,null);
- var input=channel.open();
- scriptableStream.init(input);
- var str=scriptableStream.read(input.available());
- scriptableStream.close();
- input.close();
- return str;
- },
- blast : function(num,isslide)
- {
-
- var focusElement = document.commandDispatcher.focusedElement;
- if(focusElement == null)
- {
- return;
- }
- var doc = focusElement.ownerDocument;
- /* inject script */
-
- var repaginator = new Repaginator();
-
- if(isslide != null && num != null)
- {
- repaginator.seconds = num;
- repaginator.slideshow = true;
- repaginator.nolimit = true;
- }
- else if(num != null)
- {
- repaginator.slideshow = false;
- repaginator.pagelimit = num;
- repaginator.nolimit = false;
- }
- else
- {
- repaginator.slideshow = false;
- repaginator.nolimit = true;
- }
- var searchpathtext = '';
- var range = focusElement.ownerDocument.createRange();
- range.selectNode(focusElement);
- searchpathtext = range.toString();
- var query = '//body';
- if(searchpathtext != null && searchpathtext != '')
- {
- query
- = '//a[.=\''+searchpathtext+'\'][position()=last()]';
- }
- else
- {
-
- if(focusElement.getAttribute('value') != '' &&
- focusElement.getAttribute('value') != null)
- {
- var input_value = focusElement.getAttribute('value');
-
- if(input_value != '')
- {
- query = '//input[@value=\''+input_value+'\'][position()=last()]/ancestor::a';
- }
- }
- else if(focusElement.getAttribute('src') != '' &&
- focusElement.getAttribute('src') != null)
- {
-
- var img_src = focusElement.getAttribute('src');
-
- if(img_src != '')
- {
- query = '//img[@src=\''+img_src+'\'][position()=last()]/ancestor::a';
-
- }
- }
- else if(focusElement instanceof HTMLAnchorElement)
- {
- /* get src */
- var srcObj
- = repagination.returnFirstSnapshot(doc, focusElement, 'child::*[@src]');
- if(srcObj != null)
- {
- var img_src = srcObj.getAttribute('src');
-
- if(img_src != '')
- {
- query = '//img[@src=\''+img_src+'\'][position()=last()]/ancestor::a';
- }
- }
- }
- }
-
-
- repaginator.query=query;
- repaginator.numberToIncrement = null;
- repaginator.attemptToIncrement = false;
-
- if (!this.regx2Numbers.test(query))
- {
- var test = this.regxNumber.exec(query);
- if (test)
- {
- repaginator.attemptToIncrement = true;
- repaginator.numberToIncrement = test[0];
- }
- }
-
- repaginator.blast(doc.defaultView);
- },
-
- // Register each repaginator. It is unregistered as soon as it is gotten (by its iframe).
- repaginators : new Array(),
- RegisterRepaginator : function (apg)
- {
- this.repaginators.push(apg);
- },
- GetRepaginator : function (iframe)
- {
- for (var i = 0; i < this.repaginators.length; i++)
- if (this.repaginators[i].iframe == iframe)
- {
- var found = this.repaginators[i];
- this.repaginators[i] = this.repaginators[this.repaginators.length - 1];
- this.repaginators.pop();
- return found;
- }
- return null;
- },
- returnFirstSnapshot : function (doc,node,query)
- {
- return doc
- .evaluate(query,node,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null)
- .snapshotItem(0);
- },
-
- stop : function()
- {
- if(gContextMenu == null
- || gContextMenu.target == null)
- {
- var body = window._content.document.getElementsByTagName('body')[0];
-
- if(body != null)
- {
- body.setAttribute('repagination','isOff');
- }
- }
- else
- {
- var doc = gContextMenu.target.ownerDocument;
- var body = doc.getElementsByTagName('body')[0];
-
- if(body != null)
- {
- body.setAttribute('repagination','isOff');
- }
- }
- },
- onload : function()
- {
- repagination.menu = document
- .getElementById('repagination_menu');
- var contextMenu = document
- .getElementById('contentAreaContextMenu');
- contextMenu.addEventListener('popupshowing',
- repagination.popupshowing, true);
- var urlbar = document
- .getElementById('urlbar');
- //urlbar.addEventListener('popupshowing',
- // repagination.urlcontextshowing, true);
- },
- urlcontextshowing : function(event)
- {
- var urlbar = document
- .getElementById('urlbar');
- urlbar.removeEventListener('popupshowing',
- repagination.urlcontextshowing, true);
- /**/
- var copyNode = document.getElementById('repagination_menu2');
- event.originalTarget.appendChild(copyNode);
- },
- popupshowing : function()
- {
-
- if(gContextMenu.onLink == true)
- {
- repagination.menu.hidden = false;
- return;
- }
-
- var doc = gContextMenu.target.ownerDocument;
- var body = doc.getElementsByTagName('body')[0];
-
- if(body == null)
- {
-
- repagination.menu.hidden = true;
- return;
- }
- else
- {
- var result = body.getAttribute('repagination');
- if(result == '')
- {
-
- repagination.menu.hidden = true;
- return;
- }
- else if(result == 'isOn')
- {
-
- repagination.menu.hidden = false;
- return;
- }
- else
- {
-
- repagination.menu.hidden = true;
- return;
- }
- }
- }
- };
- window.addEventListener('load',repagination.onload,true);
- ]]>
- </script>
- <popup id="contentAreaContextMenu">
- <menu label="Re-Pagination" insertafter="context-sep-properties"
- id="repagination_menu">
- <menupopup id="repagination_menupopup" onpopupshowing="event.stopPropagation();">
- <menuitem id="repagination_flatten_nolimit"
- label="All"
- oncommand="repagination.blast();"/>
- <menu id="repagination_flat_limit_menu" label="Limited">
- <menupopup onpopupshowing="event.stopPropagation();">
- <menuitem label="5" oncommand="repagination.blast(5);"/>
- <menuitem label="10" oncommand="repagination.blast(10);"/>
- <menuitem label="15" oncommand="repagination.blast(15);"/>
- <menuitem label="20" oncommand="repagination.blast(20);"/>
- <menuitem label="25" oncommand="repagination.blast(25);"/>
- <menuitem label="30" oncommand="repagination.blast(30);" />
- <menuitem label="35" oncommand="repagination.blast(35);"/>
- <menuitem label="40" oncommand="repagination.blast(40);"/>
- </menupopup>
- </menu>
- <menu id="repagination_flat_nolimit_slide" label="SlideShow">
- <menupopup onpopupshowing="event.stopPropagation();">
- <menuitem label="0 sec" oncommand="repagination.blast(0,true);"/>
- <menuitem label="1 sec" oncommand="repagination.blast(1,true);"/>
- <menuitem label="2 sec" oncommand="repagination.blast(2,true);"/>
- <menuitem label="4 sec" oncommand="repagination.blast(4,true);"/>
- <menuitem label="5 sec" oncommand="repagination.blast(5,true);"/>
- <menuitem label="8 sec" oncommand="repagination.blast(8,true);"/>
- <menuitem label="10 sec" oncommand="repagination.blast(10,true);"/>
- <menuitem label="16 sec" oncommand="repagination.blast(16,true);"/>
- <menuitem label="32 sec" oncommand="repagination.blast(32,true);"/>
- <menuitem label="64 sec" oncommand="repagination.blast(64,true);" />
- </menupopup>
- </menu>
- <menuitem id="repagination_stop"
- label="Stop"
- oncommand="repagination.stop();"/>
- </menupopup>
- </menu>
- </popup>
- <!--window id="main-window">
- <popup id="repagination_hide">
- <menu label="Re-Pagination"
- id="repagination_menu2">
- <menupopup id="repagination_menupopup2" onpopupshowing="event.stopPropagation();">
- <menuitem id="repagination_flatten_nolimit2"
- label="All"
- oncommand="repagination.increment();"/>
- <menu id="repagination_flat_limit_menu2" label="Limited">
- <menupopup onpopupshowing="event.stopPropagation();">
- <menuitem label="5" oncommand="repagination.increment(5);"/>
- <menuitem label="10" oncommand="repagination.increment(10);"/>
- <menuitem label="20" oncommand="repagination.increment(20);"/>
- <menuitem label="30" oncommand="repagination.increment(30);"/>
- <menuitem label="50" oncommand="repagination.increment(50);"/>
- <menuitem label="75" oncommand="repagination.increment(75);" />
- <menuitem label="100" oncommand="repagination.increment(100);"/>
- <menuitem label="250" oncommand="repagination.increment(250);"/>
- </menupopup>
- </menu>
- <menu id="repagination_flat_nolimit_slide2" label="SlideShow">
- <menupopup onpopupshowing="event.stopPropagation();">
- <menuitem label="0" oncommand="repagination.increment(0,true);"/>
- <menuitem label="1" oncommand="repagination.increment(1,true);"/>
- <menuitem label="2" oncommand="repagination.increment(2,true);"/>
- <menuitem label="4" oncommand="repagination.increment(4,true);"/>
- <menuitem label="5" oncommand="repagination.increment(5,true);"/>
- <menuitem label="8" oncommand="repagination.increment(8,true);"/>
- <menuitem label="10" oncommand="repagination.increment(10,true);"/>
- <menuitem label="16" oncommand="repagination.increment(16,true);"/>
- <menuitem label="32" oncommand="repagination.increment(32,true);"/>
- <menuitem label="64" oncommand="repagination.increment(64,true);" />
- </menupopup>
- </menu>
- <menuitem id="repagination_stop2"
- label="Stop"
- oncommand="repagination.stop();"/>
- </menupopup>
- </menu>
- </popup>
- </window-->
- </overlay>